package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级有关接口")
public class NursingLevelController {
    @Autowired
    private NursingLevelService nursingLevelService;

    @GetMapping("listByPage")
    @ApiOperation("分页查询护理等级")
    public ResponseResult<PageResponse<NursingLevelVo>> getByPage(String name, @RequestParam(defaultValue = "1")Integer pageNum,@RequestParam(defaultValue = "10") Integer pageSize,Integer status){
        PageResponse<NursingLevelVo> result=nursingLevelService.getByPage(name,status,pageNum,pageSize);
        return ResponseResult.success(result);
    }
    @PostMapping("/insert")
    @ApiOperation("护理等级添加")
    public ResponseResult add(@RequestBody NursingLevelDto nursingLevelDto){
        System.out.println(nursingLevelDto);
        nursingLevelService.add(nursingLevelDto);
        return ResponseResult.success();
    }
    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理等级")
    public ResponseResult selectById(@PathVariable Integer id){
        NursingLevelVo nursingLevelVo=nursingLevelService.selectById(id);
        return ResponseResult.success(nursingLevelVo);
    }
    @PutMapping("update")
    @ApiOperation("护理等级更新")
    public ResponseResult update(@RequestBody NursingLevelDto nursingLevelDto){
        nursingLevelService.update(nursingLevelDto);
        return ResponseResult.success();
    }
    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用禁用")
    public ResponseResult able(@PathVariable Long id,@ApiParam(value = "状态（0：禁用，1：启用）") @PathVariable Integer status){
        nursingLevelService.able(id,status);
        return ResponseResult.success();
    }
    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除")
    public ResponseResult delete(@PathVariable Long id){
        nursingLevelService.delete(id);
        return ResponseResult.success();
    }
    @GetMapping("listAll")
    @ApiOperation("查询所有护理等级")
    public ResponseResult getAll(){
        List<NursingLevelVo> list=nursingLevelService.getAll();
        return ResponseResult.success(list);
    }
}
